package com.gxa.jjty.admin.converter;

import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;

import java.text.SimpleDateFormat;
import java.util.Date;

@Configuration
public class DateConverter implements Converter<String, Date> {
    @Override
    public Date convert(String s) {

        try {

            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            return df.parse(s);

        }catch (Exception e){
            e.printStackTrace();
            throw new RuntimeException("日期转换失败!");
        }

    }
}
